//
//  HJAuthVC.m
//  project
//
//  Created by jc on 2019/4/13.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJAuthVC.h"
#import "HJAuthView.h"
#import "HJAuthResultVC.h"
#import "HJAuthResultView.h"
#import "HJBankListVC.h"

@interface HJAuthVC ()<AuthDelegate,AuthResultViewDelegate>
@property (nonatomic,strong) HJAuthView * authView;
@property (nonatomic,strong) HJAuthResultView * resultView;
@end

@implementation HJAuthVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    self.navTitle = @"实名认证";
}

-(void)configTableView {
    self.tableViewStyle = UITableViewStylePlain;
    [super configTableView];
    if ([HJUserManager getUserModel].auth) {
        self.tableView.tableHeaderView = self.resultView;
    }else {
        self.tableView.tableHeaderView = self.authView;
    }
}
#pragma mark --未实名认证
-(HJAuthView *)authView {
    if (!_authView) {
        _authView = [[HJAuthView alloc]init];
        _authView.frame =CGRectMake(0, 0, SCREEN_WIDTH, 593);
        _authView.delegate =self;
    }
    return _authView;
}
#pragma mark --已实名认证
-(HJAuthResultView *)resultView {
    if (!_resultView) {
        _resultView = [[HJAuthResultView alloc]init];
        _resultView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH-Height_NavBar);
        _resultView.delegate = self;
        [_resultView loadDataSource];
    }
    return _resultView;
}

#pragma mark --  AuthDelegate
-(void)authBtnClickedWithParams:(NSDictionary *)params {
    LKLog(@"实名认证");
    WS(weakSelf)
    NSString * url = [Api stringByAppendingString:AuthIdentityApi];
    [HJHttpTool post:url params:params success:^(HJResponeds *result) {
        [HJUserManager syncUserModel];
        HJAuthResultVC * authVC =[HJAuthResultVC new];
        authVC.dic = params;
        [weakSelf.navigationController pushViewController:authVC animated:YES];
    } failure:^(id result) {
        [self showErrorHUDWithError:result];
    }];
}


#pragma mark --  AuthResultViewDelegate
-(void)authResultBankButtonClicked {
    LKLog(@"银行卡");
    HJBankListVC * bankVC =[HJBankListVC new];
    [self.navigationController pushViewController:bankVC animated:YES];
}
@end
